package com.bstek.pms.tools;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/** @Description 程序入口
 * @Author hans
 * @CreateDate 2020/6/26
 */
public class Main extends Application {

  @Override
  public void start(Stage primaryStage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("index.fxml"));
    primaryStage.setTitle("BSTEK工作小助手");
    primaryStage.setScene(new Scene(root, 800, 500));
    primaryStage.show();
    primaryStage.setIconified(true); // 最小化到任务栏
    // 绑定css
    primaryStage
        .getScene()
        .getStylesheets()
        .add(getClass().getResource("/resources/css/skin.css").toExternalForm());
    //窗口关闭事件
    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent event) {
            //System.exit(0);
              MinWindow .getInstance().listen(primaryStage);
          }
        });
    init();
  }

  @Override
  public void init() throws Exception {
    ApplicationContext context =
        new ClassPathXmlApplicationContext("resources/conf/applicationContext.xml");
  }

  public static void main(String[] args) {
    launch(args);
  }
}
